﻿using System;
using System.ServiceModel;
using System.ServiceModel.Channels;
using Microsoft.Practices.Unity;
using SpectrumAnalyser.Common.Hosting;
using SpectrumAnalyser.Config.Contract;
using SpectrumAnalyser.ModelObjects.Enum;

namespace SpectrumAnalyser.Config.Client
{
    public class ConfigClient
    {
        private readonly IUnityContainer _unityContainer;

        public ConfigClient(IUnityContainer unityContainer)
        {
            this._unityContainer = unityContainer;
        }

        public void Initialize(string configServer)
        {
            Binding binding = WcfHelper.GetBinding(UriScheme.Http);

            _unityContainer.RegisterType<IConfigService, ConfigClientImpl>(new InjectionConstructor(binding,
                                                                                              new EndpointAddress(
                                                                                                  new Uri(configServer))));
        }
    }
}